﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Common;

namespace AutoFix.controls
{
    public partial class navigation : System.Web.UI.UserControl
    {
        #region [Public Properties]
        /// <summary>
        /// Sets the user type from master page
        /// </summary>
        public UserType UserType { get; set; } 
        #endregion

        #region [Event Handlers]
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (UserType == Common.UserType.Guest)
            {
                RenderGuestNavigation();
            }
            if (UserType == Common.UserType.Admin)
            {
                RenderAdminNavigation();
            }
            if (UserType == Common.UserType.Contributor)
            {
                RenderContributorNavigation();
            }
        } 
        #endregion

        #region [Private Methods]
        /// <summary>
        /// Renders the contributors navigation
        /// </summary>
        private void RenderContributorNavigation()
        {
            string navigation = @" <div id='cssmenu'>
                                <ul>
                                    <li class='active'><a href='search_article.aspx'><span>Search Repairs</span></a></li>
                                   <li class='has-sub'><a href='#'><span>Articles</span></a>
                                      <ul>
                                         <li><a href='create_article.aspx'><span>Create Article</span></a></li>
                                         <li class='last'><a href='article_list.aspx'><span>Article List</span></a></li>
                                      </ul>
                                   </li>                                   
                                </ul>
                                </div>";
            this.pnlNavigation.Text = navigation;
        }
        /// <summary>
        /// Renders the admin navigation
        /// </summary>
        private void RenderAdminNavigation()
        {

            string navigation = @" <div id='cssmenu'>
                                <ul>
                                    <li class='active'><a href='search_article.aspx'><span>Search Repairs</span></a></li>
                                   <li class='has-sub'><a href='#'><span>Articles</span></a>
                                      <ul>
                                         <li><a href='create_article.aspx'><span>Create Article</span></a></li>
                                         <li class='last'><a href='article_list.aspx'><span>Article List</span></a></li>
                                      </ul>
                                   </li>
                                   <li class='has-sub'><a href='#'><span>Vehicle Models</span></a>
                                      <ul>
                                         <li><a href='add_model.aspx'><span>Add Model</span></a></li>
                                         <li class='last'><a href='model_list.aspx'><span>Model List</span></a></li>
                                      </ul>
                                   </li>
                                </ul>
                                </div>";
            this.pnlNavigation.Text = navigation;
        }
        /// <summary>
        /// Renders the guest navigation
        /// </summary>
        private void RenderGuestNavigation()
        {
            string navigation = @" <div id='cssmenu'>
                                <ul>
                                   <li class='active'><a href='register.aspx'><span>Register</span></a></li>
                                   <li class='active'><a href='login.aspx'><span>Login</span></a></li>
                                    <li class='active'><a href='search_article.aspx'><span>Search Repairs</span></a></li>
                                </ul>
                                </div>";
            this.pnlNavigation.Text = navigation;

        } 
        #endregion
    }
}